/**
 * Created by 121 on 2016/4/08.
 */
require.config(require_config);

define([
    'jquery',
    'common',
    'ready',
    'template',
    'collection',
    'model',
    'dialog',
    'calendar',
    'highCharts'
], function ($, common, ready, template, Collection, Model, dialog, calendar, highCharts) {
    var index = function () {
        this.init();
    };
    var id = getUrlPath(4);
    console.log(id);
    index.prototype = {
        init: function () {
            this.event();
            //this.fetch();
        },
        event: function () {
            var _this = this;
            var success = function (status, id) {
                $.ajax({
                    url: _global.url.api + 'data/sample_curve',
                    type: 'get',
                    data: {status: status, id: id},
                    success: function (res) {
                        $('#sample_curve').highcharts({

                            title: {
                                text: '样本用户数据曲线',
                                x: -20 //center
                            },
                            //subtitle: {
                            //    text: 'Source: WorldClimate.com',
                            //    x: -20
                            //},
                            xAxis: {
                                categories: res.data.categories
                            },
                            yAxis: {
                                title: {
                                    text: '人/次'
                                },
                                plotLines: [{
                                    value: 0,
                                    width: 1,
                                    color: '#808080'
                                }]
                            },
                            tooltip: {
                                valueSuffix: '人'
                            },
                            legend: {
                                layout: 'vertical',
                                align: 'right',
                                verticalAlign: 'middle',
                                borderWidth: 0
                            },
                            series: [{
                                name: res.data.client_position_info,
                                data: res.data.series
                            }]
                        });
                    }
                });
            }
            success(status,id);
            $('#btn-status').find('a').on('click', function (e) {
                $(this).siblings().removeClass('active');
                e.preventDefault();
                var status = $(e.target).attr('rel');
                success(status, id);
            });
        }
    };
    new index();
});